# Python 2.6.4
# Project Euler, Problem 21
# Copyright 2010 Talha Zaman

sieve = [0 for i in range(0, 10000)]
for i in range(1,10000):
    for j in range(2*i, 10000, i):
        sieve[j] += i

sum = 0
for i in range(1, 10000):
    if (sieve[i] < 10000) and \
       (i == sieve[sieve[i]]) and \
       (i != sieve[i]): sum += i
print sum
